Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects


The Finder Application Object

The Finder application object belongs to the object class Application. As is usually the case with scriptable applications, the application object functions
as the outermost container for most of the objects the Finder defines.

To send commands to the Finder, use a Tell statement addressed to the Finder:

tell application "Finder"   open startup disk
end tell

--result: startup disk of application "Finder"
The result shown appears in the Script Editor's Result window. The statement

startup disk of application "Finder" 
is a complete reference to the startup disk. The Finder application itself is the startup disk's container. Disks, folders, and files are examples of objects that can be elements of the Finder application. Folders and files can in turn be elements of disks or of folders within disks.

You can identify nested Finder objects in a variety of ways. For example, if the startup disk is named My World, these statements all identify the same object:

folder "My Folder" of startup disk of application "Finder"folder "My Folder" of disk "My World" of application "Finder"item "My Folder" of container "My World" of application "Finder"container "My World:My Folder" of application "Finder"
When recording is turned on, the Finder always records references the same way. Although the Finder can interpret the four statements in the previous example correctly, it records the reference as shown in the first statement.

To obtain a standard reference to an element of the Finder while you're writing a script, follow these steps:

  1. Select the object.
  2. Choose Copy from the Edit menu.
  3. Activate the Script Editor application.
  4. Click at the point in your script where you want to paste the reference.
  5. Choose Paste Reference from the Edit menu.

Windows are also elements of the Finder application. You can address a Tell statement to a Finder window anywhere in a script:

tell front window of application "Finder"   close
end tell
Because window is a standard AppleScript term, AppleScript can interpret this script correctly. However, when it compiles a script, AppleScript doesn't look up the Finder's terminology definitions until after it has compiled the first line of the first Tell statement that addresses the Finder. Therefore, a script that consists of a Tell statement addressed to any other Finder object won't compile:

tell startup disk of application "Finder"   open
end tell
To address a Tell statement to a Finder object other than a window, enclose it within another Tell Statement, like this:

tell application "Finder"   tell startup disk
      open
   end tell
end tell

Subtopics
Properties and Elements of the Finder
References to Finder Windows

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996